package Demo01.Books;

import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.TreeSet;

public class ZongHeYY {
    public static void main(String[] args) {
        Set<Object> set1 = new HashSet<Object>();
        System.out.println("去重：");
        set1.add(new Book(1, "超兽武装", "蓝狐", 29, 10000));
        set1.add(new Book(2, "宇宙星神", "蓝狐", 29, 10001));
        set1.add(new Book(1, "果宝特攻", "蓝狐", 29, 10003));
        for (Object object : set1) {
            System.out.println(object);

        }
        System.out.println("********************************");
        System.out.println("按照销量从高到低排序:");
        CompareWithSale compareWithSale = new CompareWithSale();
        Set<Object> set2 = new TreeSet<Object>(compareWithSale);
        set2.add(new Book(3, "火力少年王", "奥迪双钻", 29, 10001));
        set2.add(new Book(4, "魔幻陀螺", "奥迪双钻", 30, 10002));
        set2.add(new Book(5, "战斗王之飓风战魂", "奥迪双钻", 31, 10003));
        for (Object object : set2) {
            System.out.println(object);
        }
        System.out.println("********************************");
        System.out.println("按照价格从低到高排序:");
        CompareWithPrice compareWithprice = new CompareWithPrice();
        Set<Object> set3 = new TreeSet<Object>(compareWithprice);
        set3.add(new Book(3, "博学着之怒", "王者荣耀", 2300, 10001));
        set3.add(new Book(4, "回响之杖", "王者荣耀", 2100, 10002));
        set3.add(new Book(5, "噬神之书", "王者荣耀", 2500, 10003));
        for (Object object : set3) {
            System.out.println(object);

        }
        System.out.println("********************************");
        LinkedHashSet<Object> set4=new LinkedHashSet<Object>();
        System.out.println("不可重复，按照添加顺序显示:");
        set4.add(new Book(1003,"全职法师","腾讯", 100, 10001));
        set4.add(new Book(1004,"斗罗大陆","腾讯", 350, 10002));
        set4.add(new Book(1005,"斗破苍穹","腾讯", 310, 10003));
        set4.add(new Book(1003,"喜羊羊与灰太狼","优酷", 100, 10001));
        set4.add(new Book(1004,"开心宝贝","爱奇艺", 350, 10002));
        set4.add(new Book(1005,"赛尔号","土豆", 310, 10003));
        for (Object object : set4) {
            System.out.println(object);
        }
    }
}

